<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Face Recognition Attence System<</title>
    <!-- Bootstrap core CSS -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="../css/signin.css" rel="stylesheet">
    <script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
	<header><img src="../images/logo.png" id="logo">Face Recognition Attence System</header>
    <div class="container toTop">
	  <div class="loginPanel">
      <form class="form-signin" role="form">
        <input id="empid" name="empid" type="text" class="form-control" placeholder="Emp ID" required autofocus>
        <input id="password" name="password" type="password" class="form-control" placeholder="Password" required>
        <label class="checkbox">
          <input type="checkbox" value="remember-me"> Remember me
        </label>
		<label class="checkbox">
          Forget Password?
        </label>
        <button class="btn btn-lg btn-primary btn-block" type="button" onclick="login();">Sign in</button>
		<button class="btn btn-lg btn-primary btn-block" type="button" onclick="window.location.href='../login/cameralogin.html'">Face Sign in</button>
		<button class="btn btn-lg btn-primary btn-block" type="button" onclick="window.location.href='../login/cameraregister.html'">Register</button>
      </form>
	  </div>
    </div> <!-- /container -->
	<footer>Copyright &copy; 2017 Infosys. All Rights Reserved.</footer>
  </body>
<script type="text/javascript">
var token = "";
var storage = window.localStorage;
function login(){
	$.ajax({
		type : "post",
		url : "../loginfacade/loginFacade",
		dataType : 'json',
		data : {
			empid : $("#empid").val(),
			password : $("#password").val(),
		},
		success : function(data, textStatus) {
			if (data.success) {
				token = data.token;
				var url = data.forwardUrl;
				storage.setItem("token",token);
				window.location.href = url+"?token="+token
			}
		},
		complete : function(XMLHttpRequest, textStatus) {
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			alert("Error:" + textStatus);
			alert(errorThrown.toString());
		}
	});
}
</script>
</html>

